package com.myway.service.ibe.command;

import com.travelsky.ebuild.clientapi.axi.*;
import com.travelsky.util.QDateTime;

import java.util.Vector;

/**
 * Created by yufei on 2018/6/16.
 */
public class FareSeachCommand extends BaseIBECommand{


    public void FareSeach() throws Exception{

        FareDisplay fd = new FareDisplay();
        POSType posType = this.configIBEClientPrice(fd);
        FDOdInformation fdOdInformation = new FDOdInformation();
        fdOdInformation.setOriginLocation("TBS");
        fdOdInformation.setDestinationLocation("IKA");
        //fdOdInformation.setResBookDesigCode("C");
        fdOdInformation.setDepartureDateTime(QDateTime.stringToDate("2018-06-30", "yyyy-mm-dd"));
        fdOdInformation.setArrivalDateTime(QDateTime.stringToDate("2018-06-30", "yyyy-mm-dd"));
        Vector vector = new Vector();
        vector.add(fdOdInformation);


        FDTravelPreferences fdTravelPreferences = new FDTravelPreferences();
        FDVendorPref fdVendorPref = new FDVendorPref();
        fdVendorPref.setAirlinecode("MJ");
        fdTravelPreferences.addVendorPref(fdVendorPref);
        //fdTravelPreferences.setFareDisplayCurrency("IRR");
        //fdTravelPreferences.setFareRestriction("Only");
        //fdTravelPreferences.setIncludeTaxInd(true);
       // fdTravelPreferences.setIncludeServiceFeesInd(true);
       // fdTravelPreferences.setFareAccessPreferLevel("Unacceptable");
        //fdTravelPreferences.setFareRestrictPrefLevel("Only");
        fdTravelPreferences.setFareApplicationType(FDTravelPreferences.ONEWAYTYPE);
       // fdTravelPreferences.setAdvTicketingInd(true);

        //String a1 = FDTravelPreferences.encode(fdTravelPreferences);

        FDPassengerType fdPassengerType = new FDPassengerType();
        fdPassengerType.setCode(FDPassengerType.ADULT);
        fdPassengerType.setQuantity(1);

        FareDisplayRequest request =  new FareDisplayRequest();
        request.setPos(posType);
        request.setOdInformation(vector);
        request.setTravelPreferences(fdTravelPreferences);
        request.setPricingSource(FareDisplayRequest.BOTH);
        request.setDisplayOrder(FareDisplayRequest.PriceLowtoHigh);
        request.setMaxResponses(FareDisplayRequest.MAXNUMBER);
        request.addPassengerTypeQuantity(fdPassengerType);

        FareDisplayResult fareDisplayResult = fd.displayFare(request);

        String a = fareDisplayResult.getGlobalIndicatorCode();

    }

}
